import { URL, ajax, Toast, getUser } from '../../utils/index.js'
Page({
  data: {
    activeNames: ['1'],
    upanddown:'down',
    trueclass:'fontcolor',
    queryHelpClassList:[
      {
        id:1,
        title:'使用帮助1',
        direction:'down',
        ct:false,
        c:[{id:11,title:'使用帮助1'},{id:12,title:'使用帮助2'}]
      },
      {
        id:2,
        title:'使用帮助2',
        direction:'down',
        ct:false,
        c:[{id:21,title:'使用帮助21'},{id:22,title:'使用帮助22'}]
      },
    ],
    helpClassList:[] ,
    checkedhelpClassId:''
  },
  cellClick(e){
    let {helpclassid} = e.currentTarget.dataset,checkedhelpClassId = this.data.checkedhelpClassId;
    checkedhelpClassId !='' && helpclassid === checkedhelpClassId ? helpclassid = '' : ''
    this.setData({ checkedhelpClassId : helpclassid })
  },
  childCellClick(e){
    let {helpdetailid} = e.currentTarget.dataset
    wx.navigateTo({url:`/pages/usingHelpDetails/usingHelpDetails?helpdetailid=${helpdetailid}`})
  },
  queryHelpClassList(){
    ajax.loading()
    return new Promise((resolve, reject) => {
        ajax.post('/applet/help/queryHelpClassList').then(res => {
            if (res.data.code == 1) {
                resolve(res)
                console.log('queryHelpClassList',res)
                this.setData({
                  helpClassList: res.data.data.helpClassList
                })
                ajax.toast.clear()
            } else ajax.toast.fail(res.data.msg), reject(res)
        }).catch(e => (ajax.toast.fail('接口错误queryHelpClassList'), reject(e), console.log(e)))
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.queryHelpClassList()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})